package com.study.sysuserinfo.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSort;
import com.study.exception.DigitalException;
import com.study.mapper.SysUserInfoMapper;
import com.study.model.dto.SysUserDTO;
import com.study.model.user.SysUserInfo;
import com.study.sysuserinfo.service.SysUserService;
import com.study.utils.Result;
import com.study.utils.ResultCodeEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Tag(name = "用户管理")
@RestController
@RequestMapping("/api/user")
@CrossOrigin
public class SysUserController {

    @Autowired
    private SysUserService userService;

    @GetMapping("/test")
    @Operation(description = "测试接口")
    public Result test() {
        return Result.success("测试接口");
    }
    @Operation(summary = "新增用户")
    @PostMapping("/add")
    public Result<String> addUser(@RequestBody SysUserDTO userdto) {
        Result<String> result = userService.SysUserAdd(userdto);
        return result;
    }
    // 删除用户
    @Operation(summary = "删除用户")
    @DeleteMapping("/delete/{username}") // 根据用户名删除用户
    public Result<String> deleteUser(@PathVariable String username) {
        return userService.SysUserDeleteByUsername(username);
    }
    // 修改用户
    // 根据用户名模糊查询
    // 查看所有的用户信息
    @Operation(summary = "所有用户")
    @GetMapping("/alllist")
    public Result<String> allList() {
        return Result.success("所有用户");
    }
}
